package com.todo.common.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author zhangwenxiang
 * @date 2024/3/14 21:14
 * @description
 */
@Getter
@AllArgsConstructor
public enum SourceEnum {

    PLATFORM(1, "PLATFORM", "平台内部"),
    APP(2, "APP", "APP"),
    H5(3, "H5", "H5"),
    APPLET(4, "APPLET", "小程序"),
    OUTSIDE(5, "OUTSIDE", "外部"),
    USER(6, "USER", "用户上报"),
    NONE(7, "NONE", "未知上报"),

    ;

    private static Map<Integer, SourceEnum> typeMap = Arrays
            .stream(SourceEnum.values())
            .collect(Collectors.toMap(SourceEnum::getType, item -> item, (v1, v2) -> v2));

    private int type;
    private String code;
    private String name;


    public static SourceEnum getByType(Integer type) {
        return typeMap.get(type);
    }
}
